package cn.josh.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.josh.bean.Ec_order;
import cn.josh.service.Ec_orderService;
import cn.josh.servicelmpl.Ec_orderServiceImpl;


@WebServlet("/OrderReadServlet")
public class OrderReadServlet extends HttpServlet 
{
	private static final long serialVersionUID = 1L;
       

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		//得到session对象
		HttpSession session = request.getSession();

		
		//得到用户id
		String userId = (String)session.getAttribute("userId");
		
		//将数据封装
		Ec_order ecOder = new Ec_order();
		ecOder.setUserId(userId);
		
		//取得数据库服务
		//取得数据库服务
		Ec_orderService orderDb = new Ec_orderServiceImpl();
		List<Ec_order> orderList = orderDb.findAll(ecOder);
		
		//将搜索到的集合存放在request
		request.setAttribute("orderList", orderList);
		
		request.getRequestDispatcher("jsp/order_item.jsp").forward(request, response); 
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		doGet(request, response);
	}

}
